<template>
	<view class="mt100">
		<view class="pd pt30 pm30" v-for="sd in jjhhdf" @tap="kjjhhsd(sd)">
			<view class="cf fz38 row">
				<view class="col">
					{{sd.name}}
				</view>
				<uni-icons type="down" color="#656770" size="20" class="mt5" :class="sd.cls?'xuansd':''"></uni-icons>
			</view>
			<view class="" v-if="sd.cls">
				<view @tap.stop="hf('/pages/user/TransportManagement/GroupDetails?id='+sf.id)" class="row pt20 pm20 sdfgdyswe" v-for="sf in sd.xiasdf">
					<image :src="sf.avatar" class="yj  cz uujjjmxeett"></image>
					<view class="col ml20 cf fz30">
						{{sf.name}}
					</view>
				</view>
			</view>

		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				jjhhdf: [{
					name:'我创建的',
					cls: '',
					urls:'/pages/user/TransportManagement/GroupDetails',
					xiasdf: [{
						cls: ''
					}, {
						cls: ''
					}, {
						cls: ''
					}, {
						cls: ''
					}]
				}, {
					name:'我加入的',
					cls: '',
					urls:'/pages/user/TransportManagement/GroupDetails',
					xiasdf: [{
						cls: ''
					}, {
						cls: ''
					}, {
						cls: ''
					}, {
						cls: ''
					}]
				}]
			}
		},
		components: {},
		onLoad() {
			this.mygroup(1)
			this.mygroup(2)
		},
		methods: {
			kjjhhsd(sd) {
				if (sd.cls) {
					sd.cls = ''
				} else {
					sd.cls = true
				}
			},
			async mygroup(type){				
				let groups=await this.get('/api/group/'+type+'/my')
				console.log("群组",groups)
				if(groups.code==0){
					if(type==1){
						this.jjhhdf[0].xiasdf=groups.data
					}else{
						this.jjhhdf[1].xiasdf=groups.data
					}
				}
			}
		},
		onNavigationBarButtonTap(e) {
			if(e.index==0){
				uni.showActionSheet({
					itemList:['加入群组','创建群组'],
					success: (e) => {
						if(e.tapIndex==0){
							uni.scanCode({
								success() {
									uni.navigateTo({
										url:'ApplyToJoin'
									})
								}
							})
						}else if(e.tapIndex==1){
							uni.navigateTo({
								url:'CreateGroup'
							})
						}
					}
				})
			}else 	if(e.index==1){
				uni.navigateTo({
					url:'ApplyNotification'
				})
			}
		},
		mounted() {}
	}
</script>
<style scoped>
	.uujjjmxeett {
		width: 100upx;
		height: 100upx;
	}

	.sdfgdyswe {
		line-height: 100upx;
	}

	.xuansd {
		transform: rotate(180deg)
	}
</style>
